package com.woniuxy.store.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.store.core.model.MdStorethird;
import com.woniuxy.store.core.service.MdStorethirdService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/mdStorethird")
public class MdStorethirdController {
    @Autowired
    MdStorethirdService mdStorethirdService;

    //查新所有三级菜单列表
    @GetMapping("/selectAll")
    @ApiOperation("查询三级菜单")
    public CommonResult selectAll(){
        List<MdStorethird> storethirdList=this.mdStorethirdService.list();
        return CommonResult.success(storethirdList);
    }

    //查询一个三级菜单信息
    @GetMapping("/selectOne/{thirdId}")
    public CommonResult selectOne(@PathVariable("thirdId") int thirdId) {
        MdStorethird  mdStorethird=this.mdStorethirdService.getById(thirdId);
        return CommonResult.success(mdStorethird);
    }

    //修改一个三级菜单信息信息
    @PostMapping("updateOne")
    public CommonResult updateOne(@RequestBody MdStorethird mdStorethird){
        boolean b=  this.mdStorethirdService.updateById(mdStorethird);
        if(b){
            return CommonResult.success("更新成功");}
        else {
            return CommonResult.fail();
        }
    }

    //增加一个三级菜单信息
    @PostMapping("/insertOne")
    public CommonResult insertOne(@RequestBody MdStorethird mdStorethird){
        this.mdStorethirdService.insertOne(mdStorethird);
        return CommonResult.success("插入成功");
    }
    //删除一个三级菜单信息
    @GetMapping("delectOne/{thirdId}")
    public CommonResult delectOnestore(@PathVariable("thirdId") int thirdId) {
        this.mdStorethirdService.delectOne(thirdId);
        return CommonResult.success("注销成功");
    }
}

